<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once('src/facebook.php');

class Dig_feeds extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->config->load('themes');		
		$theme = $this->config->item('dig_feeds');
		if($theme == "" || !isset($theme))
			$theme = $this->config->item('global_theme');
		
        $this->load->model('pinoytuner_model');
        
        $this->data['img_dir'] = base_url()."assets/themes/".$theme."/images/";	
        $this->data['css_dir'] = base_url()."assets/themes/".$theme."/css/";
        $this->data['js_dir'] = base_url()."assets/themes/".$theme."/js/";
        $this->data['dig_feeds'] = $this->pinoytuner_model->fetch_community_feeds('digradio');
        $this->data['title'] = "Digradio Feeds App";
		
	}
	
	public function index()
	{	
        
		$this->load->view('header',$this->data);
        $this->load->view('content',$this->data);
        $this->load->view('footer',$this->data);
	}
    
    public function get_more_feeds()
    {
        $post = $this->input->post();
        $offset = $post['offset'];
        $temp = $this->pinoytuner_model->fetch_community_feeds('digradio',4,$offset);
        $data = array();
        foreach($temp as $t)
        {
            $t['link'] = base_url().'digradio/index/'.urlencode(base64_encode(base_url().'digradio/content/'.get_type_name($t['fk-tb_mas_content_types'])."/".$t['intID']."/".simplify_title($t['strTitle'])));
            
            $data[] = $t;
        }
        if(empty($data))
        {
            $data['error'] = "error";
        }
        echo json_encode($data);
        
    }
	
			
}